package com.metaio.prototypeGPS;

import java.io.File;

import com.metaio.sdk.jni.AnnotatedGeometriesGroupCallback;
import com.metaio.sdk.jni.IAnnotatedGeometriesGroup;
import com.metaio.sdk.jni.IGeometry;
import com.metaio.sdk.jni.IMetaioSDKCallback;
import com.metaio.sdk.jni.IRadar;
import com.metaio.sdk.jni.LLACoordinate;
import com.metaio.sdk.jni.TrackingValues;
import com.metaio.sdk.jni.Vector3d;
import com.metaio.tools.io.AssetsManager;

public class MyTemplate extends MetaioSDKViewActivity {
	
	private IAnnotatedGeometriesGroup mAnnotatedGeometriesGroup;

	private MyAnnotatedGeometriesGroupCallback mAnnotatedGeometriesGroupCallback;
	
	private IGeometry campus;
	private IRadar mRadar;
	

	@Override
	protected int getGUILayout() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	protected IMetaioSDKCallback getMetaioSDKCallbackHandler() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	protected void loadContents() {
		myMetaioSDK.setTrackingConfiguration("GPS", false);
		
		TrackingValues pose=new TrackingValues();
		pose.setTranslation(new Vector3d(-1400, 0, 0));
		myMetaioSDK.setCosOffset(1, pose);
		
		mAnnotatedGeometriesGroup = myMetaioSDK.createAnnotatedGeometriesGroup();
		mAnnotatedGeometriesGroupCallback = new MyAnnotatedGeometriesGroupCallback();
		mAnnotatedGeometriesGroup.registerCallback(mAnnotatedGeometriesGroupCallback);
		
		myMetaioSDK.setLLAObjectRenderingLimits(5, 200);
		myMetaioSDK.setRendererClippingPlaneLimits(1000, 220000);
		
		File campusModel = AssetsManager.getAssetPathAsFile(
				getApplicationContext(), "metaioman.md2");
		if (campusModel != null) {
			campus = myMetaioSDK.createGeometry(campusModel);
			LLACoordinate coordinate = new LLACoordinate(45.503132, 9.168127,
					0, 0);
			campus.setTranslationLLA(coordinate);
			campus.setLLALimitsEnabled(true);
			campus.setScale(100);
		}
		
		mAnnotatedGeometriesGroup.addGeometry(campus, "campus");
		
		mRadar = myMetaioSDK.createRadar();
		mRadar.setBackgroundTexture(AssetsManager.getAssetPathAsFile(getApplicationContext(),
				"radar.png"));
		mRadar.setObjectsDefaultTexture(AssetsManager.getAssetPathAsFile(getApplicationContext(),
				"yellow.png"));
		mRadar.setRelativeToScreen(IGeometry.ANCHOR_TL);

		// add geometries to the radar
		mRadar.add(campus);
		
	}

	@Override
	protected void onGeometryTouched(IGeometry arg0) {
		// TODO Auto-generated method stub
		
	}
	
	private class MyAnnotatedGeometriesGroupCallback extends AnnotatedGeometriesGroupCallback{
		
	}
}
